<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
* 前台首页控制器
* 主要获取首页聚合数据
*/
class IndexController extends HomeController {

//系统首页
public function index(){
   //首頁廣告
   $this->ad();
   //分鋪
   $this->shop();
   //新聞
   $this->news();
   //樓盤
   $this->house();
   //關於我們
   $this->about();
   $this->hots();
   $this->hothouse();
   //顯示
   $this->display();
}
//首頁廣告
public function ad(){
   $list = D('Document')->lists(40);
   $list2 = D('Document')->detail(35);
   $this->assign('ad',$list);
   $this->assign('logo',$list2);
}
//分鋪
public function shop(){
   $list = D('Document')->lists(41);
   $this->assign('shop',$list);  
    
}
//新聞
public function news(){
   $list = D('Document')->getlist(43,0);
   $this->assign('new',$list);  
    
}
//樓盤銷售
public function house(){
      $list = D('Document')->getlist(45);
   $this->assign('house',$list);   
    
}
public function about(){
    $list = D('Document')->detail(14);
    $pic = explode(',', $list['pic']);
    $this->assign('pic',$pic);
    $this->assign('data_pic',$list);
}
/**
 * 留言板發佈
 */
public function update(){
 $res = D('Document')->update();
if(!$res){
$this->error(D('Document')->getError());

}else{
$this->success($res['id']?'發表成功':'新增成功', Cookie('__forward__'));
SendMail(C('MAIL_FROMU'),C('MAIL_FROMTITLE'),C('MAIL_CONTENT'));
}


}
/**
 * 熱門樓盤
 */
public function hothouse(){
   $list = D('Document')->getlist(45,0);
   $this->assign('hothouse',$list);  

}
/**
 * 熱門搜索
 */
public function hots(){
       
   $list = M('hots')->order('num desc')->limit(4)->select();
   $this->assign('hots',$list);
}
}